<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Commune extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function open($codePostal,$destination,$previousCommune)
	{
		$data["selectedCommune"]=$codePostal;
		$this->load->model("cities_model",'city',TRUE);
		
		$data["animateFrom"]="";
		$data["animateTo"]="";
		$data["toCommune"]="none";
		
		$toCity;
		if("FROM"==$destination){
			$data["destination"]="TO";
			$data["description"]="none";
			$data["fromCommune"]=$this->city->getCity($codePostal);
			$data["animateFrom"]="'drop'";
			
		}else if("TO"==$destination){
			$data["destination"]="FROM";
			$data["fromCommune"]=$this->city->getCity($previousCommune);
			$data["toCommune"]=$this->city->getCity($codePostal);
			$data["description"]="Information concernant commune de ".$data["fromCommune"]->name." à ".$data["toCommune"]->name;
			$data["animateTo"]="'drop'";
			$this->load->model("organisation_model",'organisation',TRUE);
			$data["organisations"]=$this->organisation->getOrganisationByZipCodes($previousCommune,$codePostal);
			
		}else{
			die("Erreur de l'application");
			
		}
		
		
		$this->render($data,'map/province','map/commune_view');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */